<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title>用户认证</title>
    <link rel="stylesheet" href="/css/bootstrap.min.css">
    <!--  指定页面字符编码为 utf-8  -->
    <meta charset="utf-8">
    <style>
        .tab-content {
            margin-top: 20px;
        }
    </style>
</head>
<body>
<div class="container mt-5">
    <div class="row justify-content-center">
        <div class="col-md-4">
            <h2 class="text-center mb-4">用户认证</h2>
            <ul class="nav nav-tabs">
                <li class="nav-item">
                    <a class="nav-link active" id="login-tab">登录</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" id="register-tab">注册</a>
                </li>
            </ul>
            <div class="tab-content">
                <!-- 登录表单 -->
                <div class="tab-pane fade show active" id="login-tab-pane">
                    <form th:action="@{/api/auth/login}" method="post">
                        <div class="form-group">
                            <label>用户名</label>
                            <input type="text" name="username" class="form-control" required>
                        </div>
                        <div class="form-group">
                            <label>密码</label>
                            <input type="password" name="password" class="form-control" required>
                        </div>
                        <button type="submit" class="btn btn-primary btn-block">登录</button>
                    </form>
                </div>

                <!-- 注册表单 -->
                <div class="tab-pane fade" id="register-tab-pane">
                    <form th:action="@{/api/auth/register}" method="post">
                        <div class="form-group">
                            <label>用户名</label>
                            <input type="text" name="username" class="form-control" required>
                        </div>
                        <div class="form-group">
                            <label>密码</label>
                            <input type="password" name="password" class="form-control" required>
                        </div>
                        <div class="form-group">
                            <label>确认密码</label>
                            <input type="password" name="confirmPassword" class="form-control" required>
                        </div>
                        <button type="submit" class="btn btn-success btn-block">注册</button>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    document.getElementById('login-tab').addEventListener('click', function() {
        document.getElementById('login-tab-pane').classList.add('show', 'active');
        document.getElementById('register-tab-pane').classList.remove('show', 'active');
        document.getElementById('login-tab').classList.add('active');
        document.getElementById('register-tab').classList.remove('active');
    });

    document.getElementById('register-tab').addEventListener('click', function() {
        document.getElementById('register-tab-pane').classList.add('show', 'active');
        document.getElementById('login-tab-pane').classList.remove('show', 'active');
        document.getElementById('register-tab').classList.add('active');
        document.getElementById('login-tab').classList.remove('active');
    });
</script>
</body>
</html>